#include <iostream>

using namespace std;

/**
 * 不高兴的津津
 * 
 */
int main(){

    int sum = 0;
    int day = 0;
    for(int i=1; i<=7;i++){
        int m,n;
        cin >> m >> n;
        
        int allHours = m+n;
        if (allHours > sum){
            day = i;
            sum = allHours;
        }
    }

    if (sum >= 8){
        cout << day;
    }else{
        cout << "0";
    }


    return 0;
}